// Decompiled by DJ v3.11.11.95 Copyright 2009 Atanas Neshkov  Date: 22/03/2011 12:26:35 p.m.
// Home Page: http://members.fortunecity.com/neshkov/dj.html  http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   UIUtils.java

package com.luxsoft.sw3.impap.ui.form;

import java.awt.Container;
import java.awt.Font;
import java.text.*;
import javax.swing.*;

public final class UIUtils
{
    public static class ToStringFormat extends Format
    {

        public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
        {
            if(obj != null)
                toAppendTo.append(obj.toString());
            return toAppendTo;
        }

        public Object parseObject(String source, ParsePosition pos)
        {
            return null;
        }

        public ToStringFormat()
        {
        }
    }


    public UIUtils()
    {
    }

    public static void increaseFontSize(Container panel, float delta)
    {
        float size = panel.getFont().getSize2D();
        Font font = panel.getFont().deriveFont(size + delta);
        updateContainerFont(panel, font);
    }

    public static void increaseFontSize(JTable grid, float delta)
    {
        float size = grid.getFont().getSize2D();
        Font font = grid.getFont().deriveFont(size + delta);
        grid.setFont(font);
    }

    public static void updateContainerFont(Container container, Font font)
    {
        int componentCount = container.getComponentCount();
        for(int i = 0; i < componentCount; i++)
        {
            java.awt.Component child = container.getComponent(i);
            if(child instanceof JPanel)
            {
                updateContainerFont((Container)child, font);
            } else
            {
                JComponent component = (JComponent)child;
                component.setFont(font);
            }
        }

    }

    public static Format buildToStringFormat()
    {
        return new ToStringFormat();
    }
}
